<!DOCTYPE html>
<html >
<head>
    <meta charset="UTF-8">
    <title>主生产计划</title>
    <script type="text/javascript">

        $(function () {
            //异步请求生产计划编号
            $.get("scgl_scjhSelect_passAndwzBang_andnoscjh",
                null,function (data) {
                    var html="<select id='scgl_scrw_scjh_documentNum'  name='scgl_scrw_scjh_documentNum' onchange=\"show_sub()\" style=\"width: 100%;height: 100%\">\n" +
                        "                            <option  name='scgl_wzxqjh_mpp_id' value=\"\">请选择一个生产计划</option>";
                    for(i=0;i<data.scglScjhs.length;i++){
                        html+= "<option value=\""+data.scglScjhs[i].scglScjhDocumentnum+"\">"+data.scglScjhs[i].scglScjhDocumentnum+"</option>";
                    }
                    html+= "</select>";

                    $("#scgl_scrw_scjh_select").append(html);

            });



        });
        //日期
        layui.use('laydate', function(){
            var laydate = layui.laydate;
            laydate.render({
                elem: '#scgl_scrw_documentDate' //指定元素
            });
            laydate.render({
                elem: '#scgl_scrw_confirmDate' //指定元素
            });
            laydate.render({
                elem: '#scgl_scrw_statementDate' //指定元素
            });
            laydate.render({
                elem: '#scgl_scrw_lastUpdateDate' //指定元素
            });

        });
        //非空验证
        function verify() {
            var scgl_scrw_documentNum = $("#scgl_scrw_documentNum").val();
            var scgl_scrw_subject = $("#scgl_scrw_subject").val();
            var scgl_scrw_scbm = $("#scgl_scrw_scbm").val();
            var scgl_scrw_machiningType = $("#scgl_scrw_machiningType").find("option:selected").val();
            var scgl_scrw_personInCharge = $("#scgl_scrw_personInCharge").val();
            var scgl_scrw_belongingProject = $("#scgl_scrw_belongingProject").val();
            var scgl_scrw_currentPlanNum = $("#scgl_scrw_currentPlanNum").val();
            var scgl_scrw_singlePlayer = $("#scgl_scrw_singlePlayer").val();
            var scgl_scrw_documentDate = $("#scgl_scrw_documentDate").val();
            var scgl_scrw_scjh_documentNum = $("#scgl_scrw_scjh_documentNum").find("option:selected").val();
            if (scgl_scrw_scjh_documentNum ==null||scgl_scrw_scjh_documentNum=="") {
                alert('源单不能为空');
                return false;
            }
            if (scgl_scrw_documentNum ==null||scgl_scrw_documentNum=="") {
                alert('单据编号不能为空');
                return false;
            }
            if (scgl_scrw_subject == null||scgl_scrw_subject=="") {
                alert('主题不能为空');
                return false;
            }
            if (scgl_scrw_scbm == null ||scgl_scrw_scbm=="") {
                alert('生产部门不能为空');
                return false;
            }
            if (scgl_scrw_machiningType =="请选择加工类型" ||scgl_scrw_machiningType=="") {
                alert('加工类型不能为空');
                return false;
            }
            if (scgl_scrw_personInCharge == null||scgl_scrw_personInCharge=="" ) {
                alert('负责人不能为空');
                return false;
            }
            if (scgl_scrw_belongingProject ==null||scgl_scrw_belongingProject=="") {
                alert('所属项目不能为空');
                return false;
            }
            if (scgl_scrw_currentPlanNum == null ||scgl_scrw_currentPlanNum=="") {
                alert('计划数量不能为空');
                return false;
            }
            if (scgl_scrw_singlePlayer ==null||scgl_scrw_singlePlayer=="" ) {
                alert('制单人不能为空');
                return false;
            }
            if (scgl_scrw_documentDate ==null||scgl_scrw_documentDate=="" ) {
                alert('制单日期不能为空');
                return false;
            }

        }
        //select的事件
        function show_sub(){
            $.get("/scgl_scjhselectOne?scglScjhDocumentnum="+$("#scgl_scrw_scjh_documentNum").find("option:selected").val(),null,
                function (data) {
                    $("#scgl_scrw_belongingProject").val(""+data.scglScjhProject+"");
                    var scgl_scrw_currentPlanNumSheng=0;
                    if(data.scglScjhAllproductionnum>data.scglScjhCompleteNum){
                         scgl_scrw_currentPlanNumSheng=data.scglScjhAllproductionnum-data.scglScjhCompleteNum;
                    }if(data.scglScjhAllproductionnum<data.scglScjhCompleteNum){
                        scgl_scrw_currentPlanNumSheng=0;
                    }
                    $("#scgl_scrw_currentPlanNumSheng").val(scgl_scrw_currentPlanNumSheng);
                    chaxunding_dan(data.scglScjhDocumentnum);
            });

        }
        function  chaxunding_dan(scglScjhDocumentnum){
                //异步请求生产订单
            $.post("/scgl_scjhmxselectOne?scglScjhDocumentnum="+scglScjhDocumentnum, null,
                function (datae) {
                    $("#scgl_scgl_thirdtable").html("");
                    var html="<tr>\n" +
                        "                        <td class=\"scgl_scgl_thirdtable_tr_td\">物品编号</td>\n" +
                        "                        <td class=\"scgl_scgl_thirdtable_tr_td\">物品名称</td>\n" +
                        "                        <td class=\"scgl_scgl_thirdtable_tr_td\">规格</td>\n" +
                        "                        <td class=\"scgl_scgl_thirdtable_tr_td\">基本单位</td>\n" +
                        "                        <td class=\"scgl_scgl_thirdtable_tr_td\">需求数量</td>\n" +
                        "                        <td class=\"scgl_scgl_thirdtable_tr_td\">计划开工日期</td>\n" +
                        "                        <td class=\"scgl_scgl_thirdtable_tr_td\">计划完工日期</td>\n" +
                        "                    </tr>";
                   if(datae==""){
                       html+="<tr>\n" +
                           "                     <td class=\"scgl_scgl_thirdtable_tr_td\"></td>\n" +
                           "                     <td class=\"scgl_scgl_thirdtable_tr_td\"></td>\n" +
                           "                     <td class=\"scgl_scgl_thirdtable_tr_td\"></td>\n" +
                           "                     <td class=\"scgl_scgl_thirdtable_tr_td\"></td>\n" +
                           "                     <td class=\"scgl_scgl_thirdtable_tr_td\"></td>\n" +
                           "                     <td class=\"scgl_scgl_thirdtable_tr_td\"></td>\n" +
                           "                     <td class=\"scgl_scgl_thirdtable_tr_td\"></td>\n" +
                           "                 </tr>";
                   }
                     if(datae!=""){
                        html+="<tr>\n" +
                            "                     <td class=\"scgl_scgl_thirdtable_tr_td\">"+datae.scglScjhmxItemnum+"</td>\n" +
                            "                     <td class=\"scgl_scgl_thirdtable_tr_td\">"+datae.scglScjhmxItemname+"</td>\n" +
                            "                     <td class=\"scgl_scgl_thirdtable_tr_td\">"+datae.scglScjhmxSpecifications+"</td>\n" +
                            "                     <td class=\"scgl_scgl_thirdtable_tr_td\">"+datae.scglScjhmxUnit+"</td>\n" +
                            "                     <td class=\"scgl_scgl_thirdtable_tr_td\">"+datae.scglScjhmxDemandnum+"</td>\n" +
                            "                     <td class=\"scgl_scgl_thirdtable_tr_td\">"+datae.scglScjhmxStartdate+"</td>\n" +
                            "                     <td class=\"scgl_scgl_thirdtable_tr_td\">"+datae.scglScjhmxOverdate+"</td>\n" +
                            "                 </tr>";
                    }


                    $("#scgl_scgl_thirdtable").append(html);

                });
        }

    </script>
    <style>
        .scgl_scgl_firstul {
            margin-top: 10px;
        }

        .scgl_scgl_firstul li {
            list-style: none;
            float: left;
            margin-left: 10px;
        }
        .scgl_scgl_firstdiv {

            height: 55px;
            width: 100%;
            border: 2px solid slategray;
        }
        .scgl_scgl_secontdiv {
            margin-top: 10px;
            width: 100%;
            height: 150px;
        }
        .scgl_scgl_firsttable {
            width: 100%;
            height: 100%;
            border:slategray 2px solid ;

        }
        .scgl_scgl_firsttable tr {
            border-bottom: 2px solid slategray;

        }
        .scgl_scgl_firsttable_tr_td {
            background-color: #FFFFF0;
            border-right: 2px solid slategray;
            width: 14%;
            height: 25%;

        }
        .scgl_scgl_firsttable_tr_td01 {
            border-right: 2px solid slategray;
            width: 14%;
            height: 25%;

        }
        .scgl_scgl_firsttable_tr_td01 input{
            border: none;
            width: 100%;
            height: 100%;
        }
        .scgl_scgl_thirdiv {
            margin-top: 10px;
            width: 100%;
            height: 300px;
        }
        .scgl_scgl_secondtable {

            width: 100%;
            height: 100%;
            border:slategray 2px solid ;
        }

        .scgl_scgl_secondtable tr{
            border-bottom: 2px solid slategray;
        }

        .scgl_scgl_secondtable_tr_td {
            background-color: #FFFFF0;
            border-right: 2px solid slategray;
            width: 14%;
            height: 14%;
        }
        .scgl_scgl_secondtable_tr_td01 input {
            border: none;
            width: 100%;
            height: 100%;
        }
        .scgl_scgl_secondtable_tr_td01 {
            border-right: 2px solid slategray;
            width: 14%;
            height: 14%;
        }
        .scgl_scgl_fourthdiv {
            margin-top: 10px;
            width: 100%;
            height: 100px;

        }
        .scgl_scgl_thirdtable {
            width: 100%;
            height: 100%;
            border:slategray 2px solid ;
            text-align: center;

        }
        .scgl_scgl_thirdtable tr{
            border-bottom: 2px solid slategray;
        }
        .scgl_scgl_thirdtable_tr_td {

            border-right: 2px solid slategray;
            width: 11%;
            height: 30px;
        }
    </style>
</head>
<body>

<div style="background-color: white">
    <!--页面主题-->
    <div style="height: 50px;width: 100%; font-weight: bold;text-align: center;font-size: 30px">新建日生产任务</div>
    <!--form表单-->
    <form action="/scgl_scrwjhjInsert" onsubmit="return verify()">
        <!--操作按钮-->
        <div class="scgl_scgl_firstdiv">
            <ul class="scgl_scgl_firstul">
                <li><input class="layui-btn layui-btn-radius" type="submit" value="保存"></li>
            </ul>
        </div>
        <!--需要填写的详细信息-->
        <div class="scgl_scgl_secontdiv">
            <table class="scgl_scgl_firsttable" cellpadding="0px" cellspacing="0px" border="2px" >
                <!--               第一行-->
                <tr>
                    <td colspan="6">基本信息</td>
                </tr>
                <!--                第二行-->
                <tr>
                    <td class="scgl_scgl_firsttable_tr_td">单据编号</td>
                    <td class="scgl_scgl_firsttable_tr_td01">
                        <input  type="text" id="scgl_scrw_documentNum" name="scgl_scrw_documentNum"/>
                    </td>
                    <td class="scgl_scgl_firsttable_tr_td">主题</td>
                    <td class="scgl_scgl_firsttable_tr_td01">
                        <input  type="text" id="scgl_scrw_subject" name="scgl_scrw_subject"/>
                    </td>
                    <td class="scgl_scgl_firsttable_tr_td">源单</td>
                    <td id="scgl_scrw_scjh_select" class="scgl_scgl_firsttable_tr_td01">

                    </td>
                </tr>
                <!--               第三行-->
                <tr >
                    <td class="scgl_scgl_firsttable_tr_td">部门</td>
                    <td  class="scgl_scgl_firsttable_tr_td01">
                        <input  type="text"  id="scgl_scrw_scbm" name="scgl_scrw_scbm"/>
                    </td>
                    <td class="scgl_scgl_firsttable_tr_td">加工类型</td>
                    <td  class="scgl_scgl_firsttable_tr_td01">
                        <select id="scgl_scrw_machiningType" name="scgl_scrw_machiningType" style="width: 100%;height: 100%">
                            <option>请选择加工类型</option>
                            <option value="自加工">自加工</option>
                            <option value="外加工">外加工</option>
                        </select>
                    </td>
                    <td class="scgl_scgl_firsttable_tr_td">负责人</td>
                    <td  class="scgl_scgl_firsttable_tr_td01">
                        <input  type="text"  id="scgl_scrw_personInCharge" name="scgl_scrw_personInCharge"/>
                    </td>
                </tr>
                <!--              第四行-->
                <tr >
                    <td class="scgl_scgl_firsttable_tr_td">所属项目</td>
                    <td colspan="5" class="scgl_scgl_firsttable_tr_td01">
                        <input  type="text" id="scgl_scrw_belongingProject"  name="scgl_scrw_belongingProject"/>
                    </td>
                </tr>
            </table>
        </div>
        <!-- /基本信息下需要填写的信息-->
        <!--     合计信息   -->
        <div class="scgl_scgl_thirdiv">
            <table class="scgl_scgl_secondtable" cellpadding="0px" cellspacing="0px" border="2px" >
                <!--               第一行-->
                <tr>
                    <td colspan="6">合计信息</td>
                </tr>
                <!--                第二行-->
                <tr>
                    <td class="scgl_scgl_secondtable_tr_td">安排计划数量合计</td>
                    <td class="scgl_scgl_secondtable_tr_td01" >
                        <input  type="text" id="scgl_scrw_currentPlanNum"  name="scgl_scrw_currentPlanNum"/>
                    </td>
                    <td class="scgl_scgl_secondtable_tr_td">剩余数量合计</td>
                    <td class="scgl_scgl_secondtable_tr_td01" colspan="3">
                        <input  type="text" readonly="readonly" id="scgl_scrw_currentPlanNumSheng"  name="scgl_scrw_currentPlanNumSheng"/>
                    </td>
                </tr>
                <!--     第三行-->
                <tr>
                    <td colspan="6">备注信息</td>
                </tr>

                <!--               第四行-->
                <tr>
                    <td class="scgl_scgl_secondtable_tr_td">单据状态</td>
                    <td class="scgl_scgl_secondtable_tr_td01">
                        <input  type="text" id="scgl_scrw_billsStatus"  name="scgl_scrw_billsStatus"/>
                    </td>
                    <td class="scgl_scgl_secondtable_tr_td">制单人</td>
                    <td class="scgl_scgl_secondtable_tr_td01">
                        <input  type="text" id="scgl_scrw_singlePlayer" name="scgl_scrw_singlePlayer"/>
                    </td>
                    <td class="scgl_scgl_secondtable_tr_td">制单日期</td>
                    <td class="scgl_scgl_secondtable_tr_td01">
                        <input type="text" name="scgl_scrw_documentDate" class="layui-input" id="scgl_scrw_documentDate">
                    </td>
                </tr>
                <!--              第五行-->
                <tr>
                    <td class="scgl_scgl_secondtable_tr_td">确认人</td>
                    <td class="scgl_scgl_secondtable_tr_td01">
                        <input  type="text" id="scgl_scrw_confirmPeople"  name="scgl_scrw_confirmPeople"/>
                    </td>
                    <td class="scgl_scgl_secondtable_tr_td">确认日期</td>
                    <td class="scgl_scgl_secondtable_tr_td01">
                        <input type="text" name="scgl_scrw_confirmDate" class="layui-input " id="scgl_scrw_confirmDate">
                    </td>
                    <td class="scgl_scgl_secondtable_tr_td">结单人</td>
                    <td class="scgl_scgl_secondtable_tr_td01">
                        <input  type="text" id="scgl_scrw_statementPeople" name="scgl_scrw_statementPeople"/>
                    </td>
                </tr>
                <!--              第六行-->
                <tr>
                    <td class="scgl_scgl_secondtable_tr_td">结单日期</td>
                    <td class="scgl_scgl_secondtable_tr_td01">
                        <input  type="text" id="scgl_scrw_statementDate" name="scgl_scrw_statementDate"/>
                    </td>
                    <td class="scgl_scgl_secondtable_tr_td">最后更新人</td>
                    <td class="scgl_scgl_secondtable_tr_td01">
                        <input  type="text" id="scgl_scrw_lastUpdatePeople" name="scgl_scrw_lastUpdatePeople"/>
                    </td>
                    <td class="scgl_scgl_secondtable_tr_td">最后更新日期</td>
                    <td class="scgl_scgl_secondtable_tr_td01">
                        <input  type="text" id="scgl_scrw_lastUpdateDate" name="scgl_scrw_lastUpdateDate"/>
                    </td>
                </tr>
                <!--     第七行-->
                <tr>
                    <td class="scgl_scgl_secondtable_tr_td">备注</td>
                    <td class="scgl_scgl_secondtable_tr_td01" colspan="5">
                        <input  type="text" id="scgl_scrw_remarks"  name="scgl_scrw_remarks"/>
                    </td>
                </tr>
            </table>
        </div>

</div>
<!--生产明细-->
<div style="width: 100%;height: 20px;margin-top: 20px"><span style="color: red;font-weight: bold">生产计划订单</span></div>
<!--生产明细的折叠框-->

<div class="layui-collapse" lay-accordion="" >
    <div class="layui-colla-item">
        <h2 class="layui-colla-title" style="text-align: center">收起栏目</h2>
        <div class="layui-colla-content layui-show" >
            <div class="scgl_scgl_fourthdiv" >
                <table id="scgl_scgl_thirdtable" class="scgl_scgl_thirdtable" cellpadding="0px" cellspacing="0px" border="2px">
                </table>
            </div>
        </div>
    </div>
</div>




<!--折叠筐的js-->
<script>
    layui.use(['element', 'layer'], function(){
        var element = layui.element;
        var layer = layui.layer;

        //监听折叠
        element.on('collapse(test)', function(data){
            layer.msg('展开状态：'+ data.show);
        });
    });
</script>
<!--/折叠筐的js-->
<!--/生产明细的折叠框-->
</form>
<!--/form表单-->
</body>
</html>